const app = getApp();
let page = 1;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    mrRoom: wx.getStorageSync('mrRoom'),
    data:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      mrRoom: wx.getStorageSync('mrRoom'),
    })

    let mrRoom = wx.getStorageSync("mrRoom")
    app.api.client_propertyBill_getPropertyBillRechargeCount({
      token: wx.getStorageSync("token"),
      idRoom: mrRoom.idRoom,
    }, (res) => {
      console.log(res)
      this.setData({
        data: res.data,
      })
    })

    

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    page = 1;
    app.api.client_propertyBill_getPropertyBillRecharges({
      token: wx.getStorageSync('token'),
      idRoom: this.data.mrRoom.idRoom,
      rows:10,
      page: page,
    }, (res) => {
      this.setData({
        list: res.data
      })
      page++
    })
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

    page = 1;
    app.api.client_propertyBill_getPropertyBillRecharges({
      token: wx.getStorageSync('token'),
      idRoom: this.data.mrRoom.idRoom,
      rows: 10,
      page: page,
    }, (res) => {
      this.setData({
        list: res.data
      })
      page++
      wx.stopPullDownRefresh();
    })



  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

    app.api.client_propertyBill_getPropertyBillRecharges({
      token: wx.getStorageSync('token'),
      idRoom: this.data.mrRoom.idRoom,
      rows: 10,
      page: page,
    }, (res) => {
      this.setData({
        list: this.data.list.concat(res.data)
      })
      page++
      wx.stopPullDownRefresh();
    })

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})